#ifndef __MAINSVR_CONFIG_H__
#define __MAINSVR_CONFIG_H__

#include "maindef.h"

class CMainConfig
{
public:
    // 共享内存
    CTSizeString<CT_PATH_MAX>	MgrShmKey;
    CTSizeString<CT_PATH_MAX>	UptShmKey;

    // ShmQueue的配置
    CTSizeString<CT_PATH_MAX>	FrontEndShmKey; ///< 前端共享内存的Key

    int     FrontEndShmSize;   ///< 前端共享内存的大小(这里是共享内存的总大小，单向队列的大小是1/2)
    CTSizeString<CT_PATH_MAX>   FrontEndSocket;    ///< 前端ENP的UnixSocketFile
    CTSizeString<CT_PATH_MAX>   BackEndSocket;     ///< 后端的UnixSocketFile

    int                         InitDataFlushNum;       //数据更新用，初始单次刷新数量
    int                         MaxDataFlushNum;        //数据更新用，最大单次更新数量

    //dbsvr相关
    CTSizeString<MAX_IPLEN>     DBHost;
    unsigned short              DBPort;

    //apisvr相关
    CTSizeString<MAX_IPLEN>     ApiHost;
    unsigned short              ApiPort;

    //memory dbsvr相关
    unsigned int                OpenMemoryDB; //是否连接内存数据库
    CTSizeString<MAX_IPLEN>     MemoryDBHost; //内存数据库
    unsigned short              MemoryDBPort;

    //大区相关
    unsigned int                ZoneID;             //大区ID
    CTSizeString<CT_PATH_MAX>   LogFilePrefix;      //日志文件名前缀

    //admin相关
    CTSizeString<MAX_IPLEN>     AdminHost;
    unsigned short              AdminPort;

    CTSizeString<CT_PATH_MAX>   SenWordCfgFilePath;  //敏感词配置路径
    CTSizeString<CT_PATH_MAX>   CrossDomainCfgFilePath;  //跨域文件配置路径

    //腾讯平台用
    CTSizeString<CT_CONF_TXT_MAX> AppID;
    CTSizeString<CT_CONF_TXT_MAX> QQMallIconPath;   //商城图标目录

    //32wan
    CTSizeString<100>           Wan32Key;           //32玩验证Key
    CTSizeString<MAX_IPLEN>     Wan32AdminHost;     //32玩对端IP
    CTSizeString<MAX_IPLEN>     Wan32AdminHost2;     //32玩对端IP

    //逻辑相关
    CTSizeString<CT_PATH_MAX>   TaskConfigFilePath;  //任务配置路径
    CTSizeString<CT_PATH_MAX>   ItemConfigFilePath;  //物品配置路径
    CTSizeString<CT_PATH_MAX>   EquipConfigFilePath;  //装备配置路径	
    CTSizeString<CT_PATH_MAX>   RoleConfigFilePath;  //角色相关配置表路径
    CTSizeString<CT_PATH_MAX>   ShopConfigFilePath;  //商店配置表路径
    CTSizeString<CT_PATH_MAX>   MonsterConfigFilePath;  //怪物相关配置表路径
    CTSizeString<CT_PATH_MAX>   InstanceConfigFilePath;  //副本相关配置表路径
    CTSizeString<CT_PATH_MAX>   PartnerConfigFilePath;  //伙伴相关配置表路径
    CTSizeString<CT_PATH_MAX>   SkillConfigFilePath;  //技能相关配置表路径
    CTSizeString<CT_PATH_MAX>   CardConfigFilePath;  //卡片相关配置表路径
    CTSizeString<CT_PATH_MAX>   SoulConfigFilePath; //魂器配置
    CTSizeString<CT_PATH_MAX>   GardenConfigFilePath; //花园配置
    CTSizeString<CT_PATH_MAX>   DrugConfigFilePath; //魔药配置
    CTSizeString<CT_PATH_MAX>   ArenaConfigFilePath; //竞技场配置
    CTSizeString<CT_PATH_MAX>   ClanConfigFilePath; //家族配置
    CTSizeString<CT_PATH_MAX>   StatusConfigFilePath;   //状态配置路径
    CTSizeString<CT_PATH_MAX>   ActConfigFilePath;      //活动配置路径
    CTSizeString<CT_PATH_MAX>   SceneConfigFilePath;    //场景配置路径
    CTSizeString<CT_PATH_MAX>   LessonConfigFilePath; //上课系统配置
    CTSizeString<CT_PATH_MAX>   SpecialAccountConfigFilePath; //版署账号
    CTSizeString<CT_PATH_MAX>   EnergyConfigFilePath;       //精力系统
    CTSizeString<CT_PATH_MAX>   DailyTaskConfigFilePath;  //任务配置路径
    CTSizeString<CT_PATH_MAX>   TreasureConfigFilePath;  //秘宝配置路径
    CTSizeString<CT_PATH_MAX>   PetConfigFilePath;  //宠物配置路径
    CTSizeString<CT_PATH_MAX>   CoolingConfigFilePath;  //冷却系统配置路径
    CTSizeString<CT_PATH_MAX>   MuseConfigFilePath;  //冥想系统配置路径
    CTSizeString<CT_PATH_MAX>   MountConfigFilePath;  //坐骑系统配置路径
    CTSizeString<CT_PATH_MAX>   FashionConfigFilePath;  //时装系统配置路径
    CTSizeString<CT_PATH_MAX>   VipConfigFilePath;  //vip系统配置路径
    CTSizeString<CT_PATH_MAX>   MagicDoorConfigFilePath;  //魔界门系统配置路径
    CTSizeString<CT_PATH_MAX>   AcademyConfigFilePath;  //学院配置
    CTSizeString<CT_PATH_MAX>   RewardConfigFilePath;  //活动奖励配置
    CTSizeString<CT_PATH_MAX>   SysOpenConfigFilePath;  //系统开启配置
    CTSizeString<CT_PATH_MAX>   DiceConfigFilePath;  //家族闯关配置
    CTSizeString<CT_PATH_MAX>   ModParaConfigFilePath;  //千分比配置
    CTSizeString<CT_PATH_MAX>   AuctionConfigFilePath;  //拍卖会配置
    CTSizeString<CT_PATH_MAX>   FriendConfigFilePath;   //好友配置
    CTSizeString<CT_PATH_MAX>   QQMallConfigFilePath;   //商城配置
    CTSizeString<CT_PATH_MAX>   PotentialConfigFilePath;  //魔晶潜能配置
    CTSizeString<CT_PATH_MAX>   ZoneConfigFilePath;         //大区配置
    CTSizeString<CT_PATH_MAX>   MarketConfigFilePath;     //任务配置

public:
    int LoadConfig();
    int ReloadConfig();

    // 读取日志配置
    int LoadLogConfig();
    int LoadDynamicConfig();

protected:
    void Ftok(char* pszPathName, size_t iLen);
};

/*
std::string GbToUtf8(const std::string  str);
int  CodeConvert(char *from_charset, char *to_charset,char *inbuf,int inlen,char *outbuf,int outlen);
*/
/** 全局配置 */
#define CONF    (CTLib::CTSingleton<CMainConfig, 0>::Instance())

#endif //__MAINSVR_CONFIG_H__
